layui.config({base: '/static/assets/libs/layuiadmin/modules/'});
layui.use(['form','common'], function(){
	let common = layui.common;
	let init = common.page.init;
	common.page.info ={
		list:{
			tableId:"table_list", //数据表格的ID
			searchFilter : 'search_filter',//搜索按钮Filter
		},
		edit:{
			submitFilter:'submit_filter',//提交按钮 Filter
			formFilter: 'from_filter',//表单 Filter
			saveUrl: "save",//保存提交的url
		},
	}
	//监听提交
	init.editSubmit();
	//关闭当前窗口
	init.escCloseLayer();
	//表单验证 value：表单的值、item：表单的DOM对象
	init.verify({
	<#list fields as field>
		${field.propertyName}: function(value, item){
			if(common.util.isEmpty(value)){
				return '${field.comment}不能为空';
			}
		<#if field.propertyType=='Integer'>
			if(!/^[0-9]*$/.test(value)){
				return '${field.comment}只能输入整数';
			}
		<#elseif field.propertyType=='String'>
			if(value.length > ${field.maxLength}){
				return '${field.comment}长度必须小于${field.maxLength}';
			}
		<#elseif field.propertyType=='Double'||field.propertyType=='Decimal'||field.propertyType=='Float'>
			if(!/^[0-9]{0,${field.maxLength-field.decimalLength}(.[0-9]{0,${field.decimalLength}})?$/.test(value)){
				return '${field.comment}最大只能由${field.maxLength-field.decimalLength}位整数和${field.decimalLength}位小数组成';
			}
		</#if>
		},
	</#list>
	});
});